package cn.zwk.product.entity;

import cn.zwk.common.utils.Tree;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

/**
 * 商品三级分类
 *
 * @author zwk
 * @email ${email}
 * @date 2024-04-19 14:59:17
 */
@Data
@TableName("pms_category")
public class CategoryEntity extends Tree<CategoryEntity> implements Serializable, Comparable<CategoryEntity>{
	private static final long serialVersionUID = 1L;

	/**
	 * 分类id
	 */
	@TableId
	private Long catId;
	/**
	 * 分类名称
	 */
	private String name;
	/**
	 * 父分类id
	 */
	private Long parentCid;
	/**
	 * 层级
	 */
	private Integer catLevel;
	/**
	 * 是否显示[0-不显示，1显示]
	 */
	@TableLogic(value = "1",delval = "0")
	private Integer showStatus;
	/**
	 * 排序
	 */
	private Integer sort;
	/**
	 * 图标地址
	 */
	private String icon;
	/**
	 * 计量单位
	 */
	private String productUnit;
	/**
	 * 商品数量
	 */
	private Integer productCount;

	@Override
	public Long getTreeId() {
		return this.getCatId();
	}

	@Override
	public Long getTreePid() {
		return this.getParentCid();
	}

	@Override
	public int compareTo(CategoryEntity o) {
		if (this.getSort()==null) return 1;
		else if (o==null||o.getSort()==null) return -1;
		return this.getSort()-o.getSort();
	}

	public CategoryEntity() {
	}

	public CategoryEntity(Long catId, Long parentCid) {
		this.catId = catId;
		this.parentCid = parentCid;
	}

	public CategoryEntity(Long catId, String name, Long parentCid, Integer catLevel, Integer showStatus, Integer sort, String icon, String productUnit, Integer productCount) {
		this.catId = catId;
		this.name = name;
		this.parentCid = parentCid;
		this.catLevel = catLevel;
		this.showStatus = showStatus;
		this.sort = sort;
		this.icon = icon;
		this.productUnit = productUnit;
		this.productCount = productCount;
	}
}
